#include "stdafx.h"
#include "LgSpriteProperty.h"

LgSpriteProperty::LgSpriteProperty(int nSpeed,int nFlyArea,const RectInBalloonElemnet_t &rect,int nMapHeight):
	m_fSpeedy((float)nSpeed/100.0f),m_nFlyArea(nFlyArea),m_MapHeight(nMapHeight)
{
	m_vecHitRect.push_back(rect);
	m_eType=(PropertyType_e)(rect.nProperty>>16);
	m_eClassName=eLgSpriteProperty;
}

LgSpriteProperty::~LgSpriteProperty(void)
{
}
void LgSpriteProperty::Update(DWORD dwCurrentTime)
{
	if(!m_bShow)return;
	DynamicLgSprite::Update(dwCurrentTime);

	m_vPosition.y += m_fSpeedy * m_fAnimationTimer;
	if (m_vPosition.y<-m_vecHitRect[0].rect.bottom||
		m_vPosition.y>m_MapHeight){
		m_bShow=false;
	}
	m_fAnimationTimer=0;

}
void LgSpriteProperty::PopUp(int a, int b,int y)
{
	m_vPosition.y=y;
	m_vPosition.x=(float)(rand()%(b+1-a)+a);
	m_nLastTime=-1;
	m_bShow=true;
}